package cn.edu.zjusc.Rmi;

import java.math.BigDecimal;
import java.util.List;

import javax.ejb.Stateless;

import org.jboss.ejb3.annotation.RemoteBinding;

import cn.edu.zjusc.Util.PersistenceHelper;
import cn.edu.zjusc.POJO.StudentDetailInfo;

@Stateless
@RemoteBinding(jndiBinding = "StudentEjbRemote")
public class StudentInfoAgent  implements IStudentRemote{
	/**
	 * 获得某个学生的详细信息
	 * 
	 * @param id
	 * @return 学生详细信息类
	 */
	public StudentDetailInfo GetStudentDetailInfoByIdName(BigDecimal id) {

		String hql = "select sdi from StudentDetailInfo  sdi left join  fetch  sdi.applyInfoBean left join  fetch  sdi.eduBkInfoBean left join  fetch  sdi.extendInfoBean where sdi.stubs_id=?1";
		Object[] params = { id };

		Object sdiBean = PersistenceHelper.getEntity(hql, params,
				StudentDetailInfo.class);

		return (StudentDetailInfo) sdiBean;
	}

	/**
	 * 获得一个考场中的所有学生
	 * @param roomNum
	 * @return
	 */
	@SuppressWarnings({ "unchecked" })
	public List<StudentDetailInfo> GetAllStudentBaseInfoByRoomNum(int roomNum) {

		String hql = "from StudentDetailInfo e where e.extendInfoBean.stuext_roomID=?1";
		Object[] params = { roomNum };

		return PersistenceHelper.executeReader(hql,params);
	}
	/**
	 * 获得一个面试分组中的所有学生
	 * @param groupNum
	 * @return
	 */
	@SuppressWarnings({ "unchecked" })
	public List<StudentDetailInfo> GetAllStudentBaseInfoByAuditionGroup(int groupNum) {

		String hql = "from StudentDetailInfo e where e.extendInfoBean.stuext_auditionGroup=?1";
		Object[] params = { groupNum };

		return PersistenceHelper.executeReader(hql,params);
	}
}
